<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
<title>Class template new_allocator</title>
<link rel="stylesheet" href="../../../../doc/src/boostbook.css" type="text/css">
<meta name="generator" content="DocBook XSL Stylesheets V1.79.1">
<link rel="home" href="../../index.html" title="The Boost C++ Libraries BoostBook Documentation Subset">
<link rel="up" href="../../boost_container_header_reference.html#header.boost.container.new_allocator_hpp" title="Header &lt;boost/container/new_allocator.hpp&gt;">
<link rel="prev" href="pmr/multimap_of.html" title="Struct template multimap_of">
<link rel="next" href="new_allocator/rebind.html" title="Struct template rebind">
<meta name="viewport" content="width=device-width, initial-scale=1">
</head>
<body bgcolor="white" text="black" link="#0000FF" vlink="#840084" alink="#0000FF">
<table cellpadding="2" width="100%"><tr>
<td valign="top"><img alt="Boost C++ Libraries" width="277" height="86" src="../../../../boost.png"></td>
<td align="center"><a href="../../../../index.html">Home</a></td>
<td align="center"><a href="../../../../libs/libraries.htm">Libraries</a></td>
<td align="center"><a href="http://www.boost.org/users/people.html">People</a></td>
<td align="center"><a href="http://www.boost.org/users/faq.html">FAQ</a></td>
<td align="center"><a href="../../../../more/index.htm">More</a></td>
</tr></table>
<hr>
<div class="spirit-nav">
<a accesskey="p" href="pmr/multimap_of.html"><img src="../../../../doc/src/images/prev.png" alt="Prev"></a><a accesskey="u" href="../../boost_container_header_reference.html#header.boost.container.new_allocator_hpp"><img src="../../../../doc/src/images/up.png" alt="Up"></a><a accesskey="h" href="../../index.html"><img src="../../../../doc/src/images/home.png" alt="Home"></a><a accesskey="n" href="new_allocator/rebind.html"><img src="../../../../doc/src/images/next.png" alt="Next"></a>
</div>
<div class="refentry">
<a name="boost.container.new_allocator"></a><div class="titlepage"></div>
<div class="refnamediv">
<h2><span class="refentrytitle">Class template new_allocator</span></h2>
<p>boost::container::new_allocator — This class is a reduced STL-compatible allocator that allocates memory using operator new. </p>
</div>
<h2 class="refsynopsisdiv-title">Synopsis</h2>
<div class="refsynopsisdiv"><pre class="synopsis"><span class="comment">// In header: &lt;<a class="link" href="../../boost_container_header_reference.html#header.boost.container.new_allocator_hpp" title="Header &lt;boost/container/new_allocator.hpp&gt;">boost/container/new_allocator.hpp</a>&gt;

</span><span class="keyword">template</span><span class="special">&lt;</span><span class="keyword">typename</span> T<span class="special">&gt;</span> 
<span class="keyword">class</span> <a class="link" href="new_allocator.html" title="Class template new_allocator">new_allocator</a> <span class="special">{</span>
<span class="keyword">public</span><span class="special">:</span>
  <span class="comment">// types</span>
  <span class="keyword">typedef</span> <span class="identifier">T</span>                      <a name="boost.container.new_allocator.value_type"></a><span class="identifier">value_type</span><span class="special">;</span>                            
  <span class="keyword">typedef</span> <span class="identifier">T</span> <span class="special">*</span>                    <a name="boost.container.new_allocator.pointer"></a><span class="identifier">pointer</span><span class="special">;</span>                               
  <span class="keyword">typedef</span> <span class="keyword">const</span> <span class="identifier">T</span> <span class="special">*</span>              <a name="boost.container.new_allocator.const_pointer"></a><span class="identifier">const_pointer</span><span class="special">;</span>                         
  <span class="keyword">typedef</span> <span class="identifier">T</span> <span class="special">&amp;</span>                    <a name="boost.container.new_allocator.reference"></a><span class="identifier">reference</span><span class="special">;</span>                             
  <span class="keyword">typedef</span> <span class="keyword">const</span> <span class="identifier">T</span> <span class="special">&amp;</span>              <a name="boost.container.new_allocator.const_reference"></a><span class="identifier">const_reference</span><span class="special">;</span>                       
  <span class="keyword">typedef</span> <span class="identifier">std</span><span class="special">::</span><span class="identifier">size_t</span>            <a name="boost.container.new_allocator.size_type"></a><span class="identifier">size_type</span><span class="special">;</span>                             
  <span class="keyword">typedef</span> <span class="identifier">std</span><span class="special">::</span><span class="identifier">ptrdiff_t</span>         <a name="boost.container.new_allocator.difference_type"></a><span class="identifier">difference_type</span><span class="special">;</span>                       
  <span class="keyword">typedef</span> <span class="identifier">implementation_defined</span> <a name="boost.container.new_allocator.propagate_on_cont_idm17826"></a><span class="identifier">propagate_on_container_move_assignment</span><span class="special">;</span>  <span class="comment">// A integral constant of type bool with value true. </span>
  <span class="keyword">typedef</span> <span class="identifier">implementation_defined</span> <a name="boost.container.new_allocator.is_always_equal"></a><span class="identifier">is_always_equal</span><span class="special">;</span>                         <span class="comment">// A integral constant of type bool with value true. </span>

  <span class="comment">// member classes/structs/unions</span>
  <span class="keyword">template</span><span class="special">&lt;</span><span class="keyword">typename</span> T2<span class="special">&gt;</span> 
  <span class="keyword">struct</span> <a class="link" href="new_allocator/rebind.html" title="Struct template rebind">rebind</a> <span class="special">{</span>
    <span class="comment">// types</span>
    <span class="keyword">typedef</span> <a class="link" href="new_allocator.html" title="Class template new_allocator">new_allocator</a><span class="special">&lt;</span> <span class="identifier">T2</span> <span class="special">&gt;</span> <a class="link" href="new_allocator/rebind.html#boost.container.new_allocator.rebind.other"><span class="identifier">other</span></a><span class="special">;</span>
  <span class="special">}</span><span class="special">;</span>

  <span class="comment">// <a class="link" href="new_allocator.html#boost.container.new_allocatorconstruct-copy-destruct">construct/copy/destruct</a></span>
  <a class="link" href="new_allocator.html#idm17852-bb"><span class="identifier">new_allocator</span></a><span class="special">(</span><span class="special">)</span> <span class="keyword">noexcept</span><span class="special">;</span>
  <a class="link" href="new_allocator.html#idm17855-bb"><span class="identifier">new_allocator</span></a><span class="special">(</span><span class="keyword">const</span> <a class="link" href="new_allocator.html" title="Class template new_allocator">new_allocator</a> <span class="special">&amp;</span><span class="special">)</span> <span class="keyword">noexcept</span><span class="special">;</span>
  <span class="keyword">template</span><span class="special">&lt;</span><span class="keyword">typename</span> T2<span class="special">&gt;</span> <a class="link" href="new_allocator.html#idm17871-bb"><span class="identifier">new_allocator</span></a><span class="special">(</span><span class="keyword">const</span> <a class="link" href="new_allocator.html" title="Class template new_allocator">new_allocator</a><span class="special">&lt;</span> <span class="identifier">T2</span> <span class="special">&gt;</span> <span class="special">&amp;</span><span class="special">)</span> <span class="keyword">noexcept</span><span class="special">;</span>
  <a class="link" href="new_allocator.html" title="Class template new_allocator">new_allocator</a> <span class="special">&amp;</span> <a class="link" href="new_allocator.html#idm17862-bb"><span class="keyword">operator</span><span class="special">=</span></a><span class="special">(</span><span class="keyword">const</span> <a class="link" href="new_allocator.html" title="Class template new_allocator">new_allocator</a> <span class="special">&amp;</span><span class="special">)</span> <span class="keyword">noexcept</span><span class="special">;</span>

  <span class="comment">// <a class="link" href="new_allocator.html#idm17832-bb">public member functions</a></span>
  <span class="identifier">pointer</span> <a class="link" href="new_allocator.html#idm17833-bb"><span class="identifier">allocate</span></a><span class="special">(</span><span class="identifier">size_type</span><span class="special">)</span><span class="special">;</span>
  <span class="keyword">void</span> <a class="link" href="new_allocator.html#idm17840-bb"><span class="identifier">deallocate</span></a><span class="special">(</span><span class="identifier">pointer</span><span class="special">,</span> <span class="identifier">size_type</span><span class="special">)</span> <span class="keyword">noexcept</span><span class="special">;</span>
  <span class="identifier">size_type</span> <a class="link" href="new_allocator.html#idm17848-bb"><span class="identifier">max_size</span></a><span class="special">(</span><span class="special">)</span> <span class="keyword">const</span> <span class="keyword">noexcept</span><span class="special">;</span>

  <span class="comment">// <a class="link" href="new_allocator.html#idm17880-bb">friend functions</a></span>
  <span class="keyword">void</span> <a class="link" href="new_allocator.html#idm17881-bb"><span class="identifier">swap</span></a><span class="special">(</span><a class="link" href="new_allocator.html" title="Class template new_allocator">new_allocator</a> <span class="special">&amp;</span><span class="special">,</span> <a class="link" href="new_allocator.html" title="Class template new_allocator">new_allocator</a> <span class="special">&amp;</span><span class="special">)</span> <span class="keyword">noexcept</span><span class="special">;</span>
  <span class="keyword">bool</span> <a class="link" href="new_allocator.html#idm17892-bb"><span class="keyword">operator</span><span class="special">==</span></a><span class="special">(</span><span class="keyword">const</span> <a class="link" href="new_allocator.html" title="Class template new_allocator">new_allocator</a> <span class="special">&amp;</span><span class="special">,</span> <span class="keyword">const</span> <a class="link" href="new_allocator.html" title="Class template new_allocator">new_allocator</a> <span class="special">&amp;</span><span class="special">)</span> <span class="keyword">noexcept</span><span class="special">;</span>
  <span class="keyword">bool</span> <a class="link" href="new_allocator.html#idm17903-bb"><span class="keyword">operator</span><span class="special">!=</span></a><span class="special">(</span><span class="keyword">const</span> <a class="link" href="new_allocator.html" title="Class template new_allocator">new_allocator</a> <span class="special">&amp;</span><span class="special">,</span> <span class="keyword">const</span> <a class="link" href="new_allocator.html" title="Class template new_allocator">new_allocator</a> <span class="special">&amp;</span><span class="special">)</span> <span class="keyword">noexcept</span><span class="special">;</span>
<span class="special">}</span><span class="special">;</span></pre></div>
<div class="refsect1">
<a name="id-1.3.9.14.18.3.4"></a><h2>Description</h2>
<div class="refsect2">
<a name="id-1.3.9.14.18.3.4.2"></a><h3>
<a name="boost.container.new_allocatorconstruct-copy-destruct"></a><code class="computeroutput">new_allocator</code> 
        public
       construct/copy/destruct</h3>
<div class="orderedlist"><ol class="orderedlist" type="1">
<li class="listitem">
<pre class="literallayout"><a name="idm17852-bb"></a><span class="identifier">new_allocator</span><span class="special">(</span><span class="special">)</span> <span class="keyword">noexcept</span><span class="special">;</span></pre>
<p>Default constructor Never throws </p>
</li>
<li class="listitem">
<pre class="literallayout"><a name="idm17855-bb"></a><span class="identifier">new_allocator</span><span class="special">(</span><span class="keyword">const</span> <a class="link" href="new_allocator.html" title="Class template new_allocator">new_allocator</a> <span class="special">&amp;</span><span class="special">)</span> <span class="keyword">noexcept</span><span class="special">;</span></pre>
<p>Constructor from other <code class="computeroutput"><a class="link" href="new_allocator.html" title="Class template new_allocator">new_allocator</a></code>. Never throws </p>
</li>
<li class="listitem">
<pre class="literallayout"><span class="keyword">template</span><span class="special">&lt;</span><span class="keyword">typename</span> T2<span class="special">&gt;</span> <a name="idm17871-bb"></a><span class="identifier">new_allocator</span><span class="special">(</span><span class="keyword">const</span> <a class="link" href="new_allocator.html" title="Class template new_allocator">new_allocator</a><span class="special">&lt;</span> <span class="identifier">T2</span> <span class="special">&gt;</span> <span class="special">&amp;</span><span class="special">)</span> <span class="keyword">noexcept</span><span class="special">;</span></pre>
<p>Constructor from related <code class="computeroutput"><a class="link" href="new_allocator.html" title="Class template new_allocator">new_allocator</a></code>. Never throws </p>
</li>
<li class="listitem">
<pre class="literallayout"><a class="link" href="new_allocator.html" title="Class template new_allocator">new_allocator</a> <span class="special">&amp;</span> <a name="idm17862-bb"></a><span class="keyword">operator</span><span class="special">=</span><span class="special">(</span><span class="keyword">const</span> <a class="link" href="new_allocator.html" title="Class template new_allocator">new_allocator</a> <span class="special">&amp;</span><span class="special">)</span> <span class="keyword">noexcept</span><span class="special">;</span></pre>
<p>Copy assignment operator from other <code class="computeroutput"><a class="link" href="new_allocator.html" title="Class template new_allocator">new_allocator</a></code>. Never throws </p>
</li>
</ol></div>
</div>
<div class="refsect2">
<a name="id-1.3.9.14.18.3.4.3"></a><h3>
<a name="idm17832-bb"></a><code class="computeroutput">new_allocator</code> public member functions</h3>
<div class="orderedlist"><ol class="orderedlist" type="1">
<li class="listitem">
<pre class="literallayout"><span class="identifier">pointer</span> <a name="idm17833-bb"></a><span class="identifier">allocate</span><span class="special">(</span><span class="identifier">size_type</span> count<span class="special">)</span><span class="special">;</span></pre>
<p>Allocates memory for an array of count elements. Throws <code class="computeroutput"><a class="link" href="bad_alloc.html" title="Class bad_alloc">bad_alloc</a></code> if there is no enough memory </p>
</li>
<li class="listitem">
<pre class="literallayout"><span class="keyword">void</span> <a name="idm17840-bb"></a><span class="identifier">deallocate</span><span class="special">(</span><span class="identifier">pointer</span> ptr<span class="special">,</span> <span class="identifier">size_type</span> n<span class="special">)</span> <span class="keyword">noexcept</span><span class="special">;</span></pre>
<p>Deallocates previously allocated memory. Never throws </p>
</li>
<li class="listitem">
<pre class="literallayout"><span class="identifier">size_type</span> <a name="idm17848-bb"></a><span class="identifier">max_size</span><span class="special">(</span><span class="special">)</span> <span class="keyword">const</span> <span class="keyword">noexcept</span><span class="special">;</span></pre>
<p>Returns the maximum number of elements that could be allocated. Never throws </p>
</li>
</ol></div>
</div>
<div class="refsect2">
<a name="id-1.3.9.14.18.3.4.4"></a><h3>
<a name="idm17880-bb"></a><code class="computeroutput">new_allocator</code> friend functions</h3>
<div class="orderedlist"><ol class="orderedlist" type="1">
<li class="listitem">
<pre class="literallayout"><span class="keyword">void</span> <a name="idm17881-bb"></a><span class="identifier">swap</span><span class="special">(</span><a class="link" href="new_allocator.html" title="Class template new_allocator">new_allocator</a> <span class="special">&amp;</span><span class="special">,</span> <a class="link" href="new_allocator.html" title="Class template new_allocator">new_allocator</a> <span class="special">&amp;</span><span class="special">)</span> <span class="keyword">noexcept</span><span class="special">;</span></pre>
<p>Swaps two allocators, does nothing because this <code class="computeroutput"><a class="link" href="new_allocator.html" title="Class template new_allocator">new_allocator</a></code> is stateless </p>
</li>
<li class="listitem">
<pre class="literallayout"><span class="keyword">bool</span> <a name="idm17892-bb"></a><span class="keyword">operator</span><span class="special">==</span><span class="special">(</span><span class="keyword">const</span> <a class="link" href="new_allocator.html" title="Class template new_allocator">new_allocator</a> <span class="special">&amp;</span><span class="special">,</span> <span class="keyword">const</span> <a class="link" href="new_allocator.html" title="Class template new_allocator">new_allocator</a> <span class="special">&amp;</span><span class="special">)</span> <span class="keyword">noexcept</span><span class="special">;</span></pre>
<p>An <code class="computeroutput"><a class="link" href="new_allocator.html" title="Class template new_allocator">new_allocator</a></code> always compares to true, as memory allocated with one instance can be deallocated by another instance </p>
</li>
<li class="listitem">
<pre class="literallayout"><span class="keyword">bool</span> <a name="idm17903-bb"></a><span class="keyword">operator</span><span class="special">!=</span><span class="special">(</span><span class="keyword">const</span> <a class="link" href="new_allocator.html" title="Class template new_allocator">new_allocator</a> <span class="special">&amp;</span><span class="special">,</span> <span class="keyword">const</span> <a class="link" href="new_allocator.html" title="Class template new_allocator">new_allocator</a> <span class="special">&amp;</span><span class="special">)</span> <span class="keyword">noexcept</span><span class="special">;</span></pre>
<p>An <code class="computeroutput"><a class="link" href="new_allocator.html" title="Class template new_allocator">new_allocator</a></code> always compares to false, as memory allocated with one instance can be deallocated by another instance </p>
</li>
</ol></div>
</div>
<div class="refsect2">
<a name="id-1.3.9.14.18.3.4.6"></a><h3>Specializations</h3>
<div class="itemizedlist"><ul class="itemizedlist" style="list-style-type: disc; "><li class="listitem"><p><a class="link" href="new_allocator_voi_idm17914.html" title="Class new_allocator&lt;void&gt;">Class new_allocator&lt;void&gt;</a></p></li></ul></div>
</div>
</div>
</div>
<div class="copyright-footer">Copyright © 2009-2018 Ion Gaztanaga<p>
        Distributed under the Boost Software License, Version 1.0. (See accompanying
        file LICENSE_1_0.txt or copy at <a href="http://www.boost.org/LICENSE_1_0.txt" target="_top">http://www.boost.org/LICENSE_1_0.txt</a>)
      </p>
</div>
<hr>
<div class="spirit-nav">
<a accesskey="p" href="pmr/multimap_of.html"><img src="../../../../doc/src/images/prev.png" alt="Prev"></a><a accesskey="u" href="../../boost_container_header_reference.html#header.boost.container.new_allocator_hpp"><img src="../../../../doc/src/images/up.png" alt="Up"></a><a accesskey="h" href="../../index.html"><img src="../../../../doc/src/images/home.png" alt="Home"></a><a accesskey="n" href="new_allocator/rebind.html"><img src="../../../../doc/src/images/next.png" alt="Next"></a>
</div>
</body>
</html>
